<%-- 
    Document   : Conference
    Created on : Dec 2, 2012, 2:31:43 PM
    Author     : Gary
--%>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Conference</title>
        <link href="<c:url value='/css/tablecss.css'/>" rel="stylesheet" type="text/css"/>
        <link href="<c:url value="/css/jquery-ui-1.9.2.custom.min.css" />" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="<c:url value="/scripts/jquery.js" />" ></script>
        <script type="text/javascript" src="<c:url value="/scripts/jquery-ui-1.9.2.custom.min.js" />" ></script>
        <script>    
            $(document).ready(function(){   
                $("#paybtn").button();
                $(this).find('a').button();
                $("#payallcheckbox").click(function() {
                    //alert("pay all.");
                    if($(this).is(':checked')) {
                        $("#bookeditemstable td input[type='checkbox']").attr('checked', 'checked');
                    } else {
                        $("#bookeditemstable td input[type='checkbox']").removeAttr('checked');
                    }
                });
            });
            function submitBookForm(itemName)
            {
                $("#bookItemName").val(itemName);
                $("#bookForm").submit();
            }  
            function pay()
            {
                var payitems = null;
                $("#bookeditemstable tr").each(function (){
                   var name = $(this).children("td.name").text();
                   var checked = ($(this).find('input:checkbox:first').is(':checked'));
                   
                   if(name != null && checked){
                       if(payitems == null){
                           payitems = name;
                       } else {
                           payitems += "&" + name;
                       }
                   }                
                });
                $("#payitems").val(payitems);
                alert(payitems);
            }
        </script>
        <jsp:include page="/Public/Header.jsp" />
    </head>
    <body class="body">

        <h1>Conference</h1>
        <div class="globalTb"><br>
            <fieldset>
                <legend class="mainLegend">Conference Detail</legend>
                <table>
                    <tr>
                        <td><b>Conference Name: </b></td>
                        <td><s:property value="conference.conferenceName"/>
                        <td><b>Event Detail: </b></td>
                        <td><s:property value="conference.eventDetail"/>
                    </tr>
                    <tr>
                        <td><b>Location: </b></td>
                        <td><s:property value="conference.locatoin"/>
                        <td><b>Price: </b></td>
                        <td><s:property value="conference.price"/>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td>
                            <a href="<s:url namespace="/member" action="touploaditem_%{conference.conferenceName}" />" class="aLinkbutton"><b>Upload Item</b></a>
                        </td>
                        <td>
                           <a href="<s:url namespace="/member" action="topayconference_%{conference.conferenceName}" />" class="aLinkbutton"><b>Pay Fee</b></a> 
                        </td>
                        <td>&nbsp;</td>
                    </tr>
                </table>
            </fieldset>
        </div><br>
        <div class="globalTb"><br>
            <fieldset style="width: 80%; height: auto">
                <legend class="mainLegend">Conference Item List</legend>
                <table class="borderAll">
                    <tr>
                        <th><s:text name="Item Name"/></th>
                        <th><s:text name="Description"/></th>
                        <th><s:text name="Category"/></th>
                        <th><s:text name="File Path"/></th>
                        <th><s:text name="Price"/></th>
                        <th><s:text name="Status"/></th>
                        <th><s:text name="Action"/></th>
                    </tr>
                    <s:iterator value="displayItems">
                        <tr class="<s:if test="#stat.odd == true">odd</s:if><s:else>even</s:else>">
                            <td><s:property value="ItemName"/></td>
                            <td><s:property value="ItemDescription"/></td>
                            <td><s:property value="Category"/></td>
                            <td><s:property value="FilePath"/></td>
                            <td><s:property value="SellPrice"/></td>
                            <td><s:property value="Status"/></td>
                            <td class="nowrap">
                                <a  href="javascript:submitBookForm('<s:property value="ItemName" />');">Book It</a>
                            </td>
                        </tr>
                    </s:iterator>
                </table>
            </fieldset>
        </div>
            <s:form namespace="/member" action="bookitem_%{conference.conferenceName}" id="bookForm" name="detailForm" method="post">
                        <input type="hidden" name="bookItemName" id="bookItemName" />
                    </s:form>
                        <br/>
                  <div class="globalTb"><br>
        <fieldset style="width: 80%; height: auto">
            <legend>Booked Items</legend>
            <s:form namespace="/member" action="topayitems_%{conference.conferenceName}">
             <table id="bookeditemstable">
            <tr>
                <th><s:text name="Item Name"/></th>
                <th><s:text name="Description"/></th>
                <th><s:text name="Category"/></th>
                <th><s:text name="File Path"/></th>
                <th><s:text name="Price"/></th>
                <th><s:text name="Status"/></th>
                <td><s:text name="Pay"/><input type="checkbox" id="payallcheckbox"/></td>
            </tr>
            <s:iterator value="bookedDisplayItems">
                <tr class="<s:if test="#stat.odd == true">odd</s:if><s:else>even</s:else>">
                    <td class="name"><s:property value="ItemName"/></td>
                    <td><s:property value="ItemDescription"/></td>
                    <td><s:property value="Category"/></td>
                    <td><s:property value="FilePath"/></td>
                    <td><s:property value="SellPrice"/></td>
                    <td><s:property value="Status"/></td>
                    <td>
                        <input id="<s:property value="ItemName"/>" type="checkbox" class="ifpay" value="1" name="payIt" id="payIt"/>
                        <input type="hidden" name="conference.callForPaper" id="callForPaper""/>
                    </td>
                </tr>
            </s:iterator>
        </table>
            <input type="submit" id="paybtn" onclick="pay();" value="Pay"/>
            <input type="hidden" name="payitems" id="payitems" />
            </s:form>
        </fieldset>
        </div>
    </body>
    <jsp:include page="/Public/Footer.jsp" />
</html>
